package com.tangxz.generate_code.util;


public class FieldUtil {
    public static String encoding = "UTF-8";

    public FieldUtil() {
    }


    public static String toExcludePrefix(String Name) {
        String[] s = Name.split("_");
        //去掉一个str第一个_前面的部分
        //act_,ext_act_,design_,onl_,sys_,qrtz_
        if (s.length > 1&& s[0].equals("user_")||s.length>2){
            return ToCamelCase(Name.substring(s[0].length() + 1));
        }
        return ToCamelCase(Name);
    }

    //首字母大写驼峰命名
    public static String ToCamelCase(String str) {
        str = str.toLowerCase();
        String[] ss = str.split("_");
        StringBuilder sb = new StringBuilder();
        if (ss.length > 0) {
            for (String s : ss) {
                sb.append((char) (s.charAt(0) - 32));
                sb.append(s.substring(1));
            }
        }
        return sb.toString();
    }

    //首字母小写驼峰命名
    public static String toCamelCase(String str) {
        str = str.toLowerCase();
        String[] ss = str.split("_");
        StringBuilder sb = new StringBuilder();
        if (ss.length > 0) {
            sb.append(ss[0]);
            for (int i = 1; i < ss.length; i++) {
                sb.append((char) (ss[i].charAt(0) - 32));
                sb.append(ss[i].substring(1));
            }
        }
        return sb.toString();
    }

    public static String fieldValue(String value) {
        return "'" + value + "'";
    }
}
